
Ext.require([
    'Ext.tab.*',
    'Ext.window.*',
    'Ext.tip.*',
    'Ext.layout.container.Border'
]);
Ext.onReady(function(){
    var win,
        button = Ext.get('show-btn');

    button.on('click', function(){

        if (!win) {
            win = Ext.create('widget.window', {
        height: 200,
        width: 400,
        x: 450,
        y: 450,
        title: 'Constraining Window, plain: true',
        closable: true,
        plain: true,
        layout: 'fit',
        items: [floater = Ext.create('Ext.Component', {
            xtype: 'component',
            floating: {
                shadow: false
            },
            height: 50,
            width: 50,
            x: 175,
            y: 75
        }), formPanel = Ext.widget('form', {

        frame: true,
        width: 350,
        bodyPadding: 20,
        bodyBorder: true,
        title: 'INICIO DE SESION',

        defaults: {
            anchor: '100%'
        },

        items: [{
            xtype: 'textfield',
            name: 'login',
            fieldLabel: 'Usuario',
            allowBlank: false,
           
        }, {
            xtype: 'textfield',
            name: 'password',
            fieldLabel: 'Password',
            inputType: 'password',
            style: 'margin-top:10px',
            allowBlank: false,
           
        }],

        dockedItems: [{
            xtype: 'container',
            dock: 'bottom',
            layout: {
                type: 'hbox',
                align: 'middle'
            },
            padding: '5 5 5',

            items: [{
                xtype: 'button',
                formBind: true,
                disabled: true,
                text: 'LOGIN',
                width: 140,
                handler: function() {
                    var form = this.up('form').getForm();
                    form.submit({
                        url: 'login',			

                    });
				    win.hide(this, function() {
						button.dom.disabled = false;
					});
					window.location.reload();
                    
                }
            }]
        }]
    }),{
            border: false
        }]
    });
        }
        button.dom.disabled = true;
        if (win.isVisible()) {
            win.hide(this, function() {
                button.dom.disabled = false;
            });
        } else {
            win.show(this, function() {
                button.dom.disabled = false;
            });
        }
    });
});
